package com.tengju.bff.interfaces.login.assembler;

import com.tengju.bff.interfaces.login.vo.ManMachineValidateRegisterVO;
import com.tengju.user.application.login.dto.CheckSmsCodeDTO;
import com.tengju.user.application.login.dto.SendSmsCodeDTO;
import com.tengju.user.application.login.dto.SendSmsCodeV2DTO;
import com.tengju.user.domain.model.login.UserType;
import com.tengju.user.domain.model.sms.CheckSmsCodeData;
import com.tengju.user.domain.model.sms.ManMachineValidateRegister;
import com.tengju.user.domain.model.sms.OperationType;
import com.tengju.user.domain.model.sms.SendSmsVerifyCodeData;

/**
 * @author wuziyang
 */
public class SmsCodeAssembler {

    public static SendSmsVerifyCodeData dtoToModel(SendSmsCodeDTO sendSmsCodeDTO) {

        return new SendSmsVerifyCodeData(
                sendSmsCodeDTO.getAreaCode(),
                sendSmsCodeDTO.getMobile(),
                UserType.fromVal(sendSmsCodeDTO.getUserType()),
                OperationType.fromVal(sendSmsCodeDTO.getOperationType()),
                null,null,null
        );

    }

    public static SendSmsVerifyCodeData dtoToModel(SendSmsCodeV2DTO sendSmsCodeV2DTO) {

        return new SendSmsVerifyCodeData(
                sendSmsCodeV2DTO.getAreaCode(),
                sendSmsCodeV2DTO.getMobile(),
                UserType.fromVal(sendSmsCodeV2DTO.getUserType()),
                OperationType.fromVal(sendSmsCodeV2DTO.getOperationType()),
                sendSmsCodeV2DTO.getChallenge(),
                sendSmsCodeV2DTO.getValidate(),
                sendSmsCodeV2DTO.getSecCode()
        );

    }

    public static CheckSmsCodeData dtoToModel(CheckSmsCodeDTO checkSmsCodeDTO) {

        return new CheckSmsCodeData(checkSmsCodeDTO.getAreaCode(),
                checkSmsCodeDTO.getMobile(),
                UserType.fromVal(checkSmsCodeDTO.getUserType()),
                OperationType.fromVal(checkSmsCodeDTO.getOperationType()),
                checkSmsCodeDTO.getCode()
        );

    }

    public static ManMachineValidateRegisterVO convertToVo(ManMachineValidateRegister register) {

        return new ManMachineValidateRegisterVO(
                register.getGt(),
                register.getChallenge(),
                register.getSuccess()
        );

    }
}
